import QtQuick 1.1
import com.nokia.meego 1.0
import "HarmattanUIConstants.js" as Constants

HeaderLabel {
    id: folderListControl

    property bool showFileControl: false
    property alias currentFolder: currentFolderText.text
    property alias filename: fileControlText.text

    signal parentFolderRequested()
    signal saveRequested()

    height: fileControl.visible ?
                pathControl.height + fileControl.height :
                pathControl.height;

    Item {
        id: pathControl
        width: parent.width
        height: Constants.DEFAULT_LIST_ITEM_HEIGHT
        anchors.top: parent.top

        Row {
            width: parent.width - 2 * Constants.DEFAULT_MARGIN
            height: parent.height - Constants.DEFAULT_MARGIN
            anchors.centerIn: parent
            spacing: Constants.DEFAULT_MARGIN

            TextField {
                id: currentFolderText
                width: parent.width - folderUpButton.width - Constants.DEFAULT_MARGIN
                height: Constants.DEFAULT_TEXT_FIELD_HEIGHT
                readOnly: true
            }

            Button {
                id: folderUpButton
                width: Constants.DEFAULT_BUTTON_WIDTH
                height: Constants.DEFAULT_BUTTON_HEIGHT
                iconSource: "folder_up_icon.png"
                onClicked: folderListControl.parentFolderRequested()
            }
        }
    } // pathControl

    Item {
        id: fileControl
        width: parent.width
        height: Constants.DEFAULT_LIST_ITEM_HEIGHT
        anchors.top: pathControl.bottom
        visible: showFileControl ? true : false;

        Row {
            width: parent.width - 2 * Constants.DEFAULT_MARGIN
            height: parent.height - Constants.DEFAULT_MARGIN
            anchors.centerIn: parent
            spacing: Constants.DEFAULT_MARGIN

            TextField {
                id: fileControlText
                width: parent.width - fileControlButton.width -
                       Constants.DEFAULT_MARGIN
                height: Constants.DEFAULT_TEXT_FIELD_HEIGHT
                readOnly: false
            }

            Button {
                id: fileControlButton
                width: Constants.DEFAULT_BUTTON_WIDTH
                height: Constants.DEFAULT_BUTTON_HEIGHT
                text: "Save"
                enabled: (fileControlText.text.length > 0)
                onClicked: folderListControl.saveRequested()
            }
        }
    } // fileControl
}

// End of file.
